#include <linux/module.h>
#include <linux/printk.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/sched.h>

static int num = 0;

static int proc_count_show(struct seq_file *s, void *v){
	struct task_struct *p = NULL;
  	for_each_process(p)
  	{
	  num ++;
  	}
	seq_printf(s,"%d\n",num);
	return 0;
}

static int __init proc_count_init(void)
{
	pr_info("proc_count: init\n");

	proc_create_single("count",0,NULL,proc_count_show);
	
	
	return 0;
}

static void __exit proc_count_exit(void)
{
	pr_info("proc_count: exit\n");
	remove_proc_entry("count",NULL);
}

module_init(proc_count_init);
module_exit(proc_count_exit);

MODULE_AUTHOR("Guojian Chen");
MODULE_DESCRIPTION("A module to feedback the number of running processes");
MODULE_LICENSE("GPL");
